package com.genius.adminmanager.group.controller;

import javax.servlet.http.HttpSession;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONObject;
import com.genius.adminmanager.group.service.GroupService;
import com.genius.adminmanager.menu.entity.MenuJson;
import com.genius.adminmanager.other.entity.ResponseJson;

@Controller
public class GroupSelectController {
	
	@Autowired
	@Qualifier("groupSelectService")
    private GroupService groupSelectService;
	
	/**
	 * 跳转到列表页面
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@RequiresPermissions("a64e4c0eed2a48ffbc5cfb9e8216b58d")
	@GetMapping("/adminmanager/group/toSelect")
	public String toMenuList(){
		return "/views/adminmanager/group/select";
	}
	
	/**
	 * 查看列表
	 * 根据传入的id查看该页面显示的数据是否有权限
	 * @return
	 * @throws Exception
	 */
	@GetMapping("/adminmanager/group/getSelectHead")
	@ResponseBody
    public JSONObject getSelectHead(HttpSession session){
    	JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	JSONObject json = new JSONObject();
        json.put(MenuJson.menuId, "a64e4c0eed2a48ffbc5cfb9e8216b58d");
    	response = groupSelectService.getSelectHead(json, session, response);
    	return response;
    }
	/**
	 * 查询数据
	 * @return
	 * @throws Exception
	 */
	@PostMapping("/adminmanager/group/getSelectBody")
	@ResponseBody
    public JSONObject getSelectBody(@RequestBody JSONObject json){
    	JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = groupSelectService.getSelectBody(json, response);
    	return response;
    }
}
